package hunterxhunter.greedisland.data;

import java.io.Serializable;

/**
 *
 * @author Markus Schr&ouml;der
 */
public class Slot implements Serializable {

    private final int NO_CARD = -1;
    
    private int slotNumber;
    private int realCard;
    private int fakeCard;
    
    public Slot(int slotNumber) {
        this.slotNumber = slotNumber;
        this.realCard = NO_CARD;
        this.fakeCard = NO_CARD;
    }
    
    public void collectCard(int cardNumber) {
        this.realCard = cardNumber;
    }
    
    public Card getCard() {
        if(!hasCard())
            return null;
        return CardManager.getInstance().getCard(getCardNumber());
    }
    
    public int getCardNumber() {
        if(isFake()) {
            return fakeCard;
        }
        if(isReal()) {
            return realCard;
        }
        return NO_CARD;
    }
    
    public Card getRealCard() {
        if(!hasCard())
            return null;
        return CardManager.getInstance().getCard(realCard);
    }
    
    public boolean isFake() {
        return fakeCard != NO_CARD;
    }
    
    public boolean isReal() {
        return !isFake() && realCard != NO_CARD;
    }
    
    public boolean isFixed() {
        return slotNumber >= 0 && slotNumber <= 99;
    }
    
    public boolean isFree() {
        return slotNumber >= 100 && slotNumber <= 144;
    }
    
    public boolean hasCard() {
        return getCardNumber() != NO_CARD;
    }
    
    public boolean hasCorrectCard() {
        if(isFree())
            return true;
        
        return slotNumber == realCard;
    }

    /**
     * @return the slotNumber
     */
    public int getSlotNumber() {
        return slotNumber;
    }
    
}
